<template>
  <div class="alone-outBox f14">
    <div class="alone-topBox mb16">
      <div class="flex flex-warp flex_bt">
        <div class="flex flex-warp" style="align-items:center">
          <div class="mb16">
            <span>关键字：</span>
            <el-input v-model="searchObj.keyWords" placeholder="请输入关键字" class="width200 mr16" />
          </div>
          <div class="mb16 mr16">
            <span>所属行业：</span>
            <el-select v-model="searchObj.industry" placeholder="请选择" class="width200" clearable @change="changestatus">
              <el-option v-for="item in industryTypeList" :key="item.name" :label="item.name" :value="item.name" />
            </el-select>
          </div>
          <div class="mb16 mr16">
            <span>单位类型：</span>
            <el-select v-model="searchObj.unitType" placeholder="请选择" class="width200" clearable
              @change="changeCompanyType">
              <el-option v-for="item in companyTypeList" :key="item.name" :label="item.name" :value="item.id" />
            </el-select>
          </div>
          <div class="mb16 mr16">
            <span>职位：</span>
            <el-select v-model="searchObj.dutyType" placeholder="请选择" class="width200" clearable @change="changestatus">
              <el-option v-for="item in postionTypeList" :key="item.name" :label="item.name" :value="item.id" />
            </el-select>
          </div>

          <div class="mb20">
            <el-button @click="React">重置</el-button>
            <el-button type="primary" @click="SearchListBt">筛选</el-button>
          </div>
        </div>
        <div>
        </div>
      </div>
    </div>
    <div class="tableBox">
      <!-- 表格 -->
      <el-table v-loading="loading" :data="DataTable" style="width: 100%" max-height="620"
        :default-sort="{ prop: 'date', order: 'descending' }">
        <el-table-column prop="name" label="姓名" min-width="150">
          <template slot-scope="scope">
            <div>
              <el-link type="primary" @click="openDialog3(scope.row)">{{
                scope.row.name
              }}</el-link>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="mobile" label="手机" min-width="150" align="left" />
        <el-table-column prop="email" label="邮箱" min-width="250" align="left">
        </el-table-column>
        <el-table-column prop="industry" label="所属行业" min-width="150" align="left">
        </el-table-column>
        <el-table-column prop="unitType" label="单位类型" min-width="160" align="left" />
        <el-table-column prop="company" min-width="350" label="单位名称" />
        <el-table-column prop="dutyType" label="职位" min-width="120" align="left">
          <template slot-scope="scope">
            {{ scope.row.lyState }}
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="120" fixed="right" align="center">
          <template slot-scope="scope">
            <el-button type="text" class="mr10" @click="openDialog3(scope.row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="alignRight">
        <Pagination :total="total" :page="searchObj.page" :limit="searchObj.limit" @pagination="paginations" />
      </div>
    </div>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination/index.vue'
import Cookies from 'js-cookie'
import indexapi from '@/api/index'

export default {
  components: {
    Pagination
  },
  data() {
    return {
      activeName: 'first',
      datatime: [],
      searchObj: {
        imshowId: Cookies.get('imShowId')
          ? Cookies.get('imShowId')
          : '',
        keyWords: '',
        limit: 10,
        page: 1,
        unitType: '',
        industry: '',
        dutyType: ''
      },
      total: 0,
      loading: false,
      reasonDia: false,
      returnReason: '',
      classification: [
        { name: '待审核', value: 0 },
        { name: '已录用', value: 1 },
        { name: '已退回', value: 2 }
      ],
      DataTable: [],
      fileList: [],
      id: 33212,
      industryTypeList: [],
      companyTypeList: [],
      postionTypeList: []
    }
  },
  mounted() {
    this.getTypeList()
    this.selectUnitType()
    // this.getclassification();
    this.SearchList()
  },
  methods: {
    // 获取单位类型
    selectUnitType() {
      const form = {
        parentid: 0,
        typename: 'DWLX'
      }
      indexapi.video.selectUnitType(form).then((res) => {
        this.companyTypeList = res.data
      })
    },
    // 获取职位类型
    selectPositionType(companyTypeId) {
      const form = {
        parentid: companyTypeId,
        typename: 'ZWLX'
      }
      indexapi.video.selectUnitType(form).then((res) => {
        this.postionTypeList = res.data
      })
    },
    // 获取行业类型
    getTypeList() {
      indexapi.support.getIndustryClassifySelectByLevel().then((res) => { // 获取行业分类
        if (res.code == 200) {
          this.industryTypeList = res.data.data
        }
      })
    },
    // 改变推荐状态
    changetj(val, row) {
      const form = {
        paperId: row.id,
        recommend: val
      }
      api.solution.setPaperCommend(form).then((res) => {
        if (res.data > 0) {
          this.$message({ type: 'success', message: '修改推荐状态成功！' })
          this.SearchList()
        } else if (res.data == 0) {
          this.$message({ type: 'error', message: '推荐个数不足!' })
          this.SearchList()
        } else {
          this.$message({ type: 'error', message: '推荐权限未初始化!' })
          this.SearchList()
        }
      })
    },
    // 查看理由
    checkreason(val) {
      this.reasonDia = true
      this.returnReason = val.returnReason
    },
    // 改变状态
    changestatus() {
      this.SearchListBt()
    },
    // 选择单位类型触发
    changeCompanyType() {
      this.selectPositionType(this.searchObj.unitType)
    },
    // 删除
    deletePaper(val) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          const form = {
            paperId: val.id,
            imshowId: Cookies.get('imShowId')
              ? Cookies.get('imShowId')
              : '0'
          }
          indexapi.solution.deletePaper(form).then((res) => {
            if (res.code == 200) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              })
              this.SearchList()
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 获取分类数据
    getclassification() {
      indexapi.DataCenter.paperSortLevel().then((res) => {
        this.classification = res.data
        this.SearchList()
      })
    },
    // 跳转
    openDialog(val) {
      window.open(
        `https://www.instrument.com.cn/netshow/${val.imshowID}/s${val.id}.htm`
      )
    },
    // 跳转2
    openDialog2(val) {
      window.open(
        `https://www.instrument.com.cn/application/Solution-${val.id}.html`
      )
    },
    // 跳转3
    openDialog3(val) {
      if (val) {
        this.$router.push({ path: '/user/userDetail', query: { personId: val.personId, userName: val.userName } })
      }
    },
    // 编辑
    editPaper(val) {
      this.$router.push({ path: '/user/userDetail', query: { personId: val.id } })
    },
    // 重置
    React() {
      this.searchObj = {
        imshowId: Cookies.get('imShowId')
          ? Cookies.get('imShowId')
          : '',
        keyWords: '',
        status: '',
        limit: 10,
        page: 1,
        recommend: null
      }
      this.datatime = []
      this.SearchList()
    },
    // 查询
    SearchListBt() {
      this.searchObj.limit = 10
      this.searchObj.page = 1
      this.SearchList()
    },
    SearchList() {
      this.loading = true

      indexapi.video.getMeetPersonByImshowId(this.searchObj).then((res) => {
        this.loading = false
        this.DataTable = res.data.records

        this.total = res.data.total
      })
    },
    // 分页
    paginations(val) {
      this.searchObj.limit = val.limit
      this.searchObj.page = val.page
      this.SearchList()
    },
    releaseInformation() {
      this.$router.push('/content/solutionscheme/solution/addoredit')
    }
  }
}
</script>
<style scoped>
.topButton {
  position: absolute;
  right: 20px;
  top: 16px;
}

.flex_bt {
  justify-content: space-between;
}

.icon_right {
  font-weight: 600;
  color: #0c7ff2;
  cursor: pointer;
  font-size: 18px;
}
</style>
